<template>
  <div>
    <HomePanel ref="target" title="新鲜好物" subTitle="新鲜出炉 品质靠谱">
      <template #right>
        <XtxMore path="/" />
      </template>
      <template #default>
        <!-- <ul ref="pannel" class="goods-list">
          <li v-for="item in newData" :key="item.id">
            <RouterLink to="/">
              <img :src="item.picture" alt="" />
              <p class="name">{{ item.name }}</p>
              <p class="price">&yen;{{ item.price }}</p>
            </RouterLink>
          </li>
        </ul> -->
        <HomeNewList :list="newData" />
      </template>
    </HomePanel>
  </div>
</template>

<script>
import HomePanel from '@/views/Home/components/HomePanel.vue'
import HomeNewList from '@/views/Home/components/HomeNewList.vue'
import { findNew } from '@/api/home.js'
import { ref } from 'vue'
import { UseObserve } from '@/hook'

export default {
  components: { HomePanel, HomeNewList },
  setup () {
    const newData = ref([])
    const getNewData = async () => {
      const res = await findNew()
      console.log('新鲜好物', res)
      newData.value = res.result
    }
    const { target } = UseObserve(getNewData)

    // onMounted(() => {
    //   getNewData()
    // })
    return { newData, target }
  }
}
</script>

<style lang="less" scoped>
// .goods-list {
//   display: flex;
//   justify-content: space-between;
//   height: 406px;
//   li {
//     width: 306px;
//     height: 406px;
//     background: #f0f9f4;
//     // 激活效果
//     transition: all 0.5s;
//     &:hover {
//       transform: translate3d(0, -6px, 0);
//       box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
//     }
//     // end
//     img {
//       width: 306px;
//       height: 306px;
//     }
//     p {
//       font-size: 22px;
//       padding-top: 12px;
//       text-align: center;
//       text-overflow: ellipsis;
//       overflow: hidden;
//       white-space: nowrap;
//     }
//     .price {
//       color: @priceColor;
//     }
//   }
// }
</style>
